home *** CD-ROM | disk | FTP | other *** search
/ Programming Microsoft Visual Basic .NET / Programming Microsoft Visual Basic .NET (Microsoft Press)(X08-78517)(2002).bin / 07 attributes / attributesdemo / customattribute.vb < prev    next >
Text File  |  2002-03-16  |  966b  |  37 lines

  1. ' The AttributeTargets.All value means that this attribute
  2. ' can be used with any program entity.
  3.  
  4. <AttributeUsage(AttributeTargets.All)> _
  5. Class VersioningAttribute
  6.     ' All attribute classes inherit from System.Attribute.
  7.     Inherits System.Attribute
  8.  
  9.     ' These should be Property procedures in a real application
  10.     ' but fields are OK in this demo.
  11.     Public Author As String
  12.     Public Version As Single
  13.     Public Tested As Boolean
  14.  
  15.     ' The Attribute constructor takes two non-optional values.
  16.     Sub New(ByVal Author As String, ByVal Version As Single)
  17.         Me.Author = Author
  18.         Me.Version = Version
  19.     End Sub
  20. End Class
  21.  
  22.  
  23.  
  24. ' a class to test the Versioning attribute
  25.  
  26. <Versioning("John", 1.01)> _
  27. Class TestClass
  28.     <Versioning("Robert", 1.01, Tested:=True)> _
  29.     Sub MyProc()
  30.         '
  31.     End Sub
  32.  
  33.     <Versioning("Ann", 1.02)> _
  34.     Function MyFunction() As Long
  35.         '
  36.     End Function
  37. End Class